<template>
  <div class="container">
    <div class="screen" ref="screen">
      <div class="top"></div>
      <div class="bottom"></div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';
//获取数据大屏展示内容盒子的DOM元素
let screen = ref();
onMounted(() => {
    screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
});
//定义大屏缩放比例
function getScale(w = 1920, h = 1080) {
    const ww = window.innerWidth / w;
    const wh = window.innerHeight / h;
    return ww < wh ? ww : wh;
}
//监听视口变化
window.onresize = () => {
    screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
}
</script>

<style scoped>
.container {
  text-align: center;
  width: 100vw;
  height: 100vh;
  background: red;
  .screen{
    width: 1920px;
    height: 1080px;
    background: blue;
    position: fixed;
    left: 50%;
    top: 50%;
    transform-origin: left top;
  }
}
</style>